package com.simple.common.enumdto;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @ClassName BillType
 * @Author SimpleTree
 **/
@Getter
@AllArgsConstructor
public enum BillType {
    dinner(1,"正餐"),
    meat(2,"在外吃饭"),
    duoduo(3,"多多买菜"),
    meituan(4,"美团优选"),
    tcc(5,"淘菜菜"),
    hm(6,"盒马集市"),
    snacks(7,"零食(绝味鸭脖，周黑鸭,奶茶等)"),
    qqk(8,"亲情卡"),
    fare(9,"车费"),
    rent(10, "房租"),
    hb(11, "红包"),
    parent(12, "父母"),
    pouch(13,"小荷包"),
    travel(14, "旅游"),
    other(99,"其他")

    ;

    private Integer code;
    private String msg;

    public static Integer getCode(String msg) {
        return Arrays.stream(BillType.values()).filter(billType -> msg.equals(billType.getMsg())).findFirst().map(BillType::getCode).orElse(-1);
    }

    public static String getMsg(Integer code) {
        return Arrays.stream(BillType.values()).filter(billType -> code.equals(billType.getCode())).findFirst().map(BillType::getMsg).orElse("未知异常");
    }

}
